<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>系统登录 - 流浪动物管理系统</title>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <script type="text/javascript">
        /* if(top.location!=self.location){
              top.location=self.location;
         } */
    </script>
</head>
<div id="quan1">
<body class="login_bg">
<div id="app">
    <section class="loginBox">
        <header class="loginHeader">
            <h1>流浪动物管理系统</h1>
        </header>
        <section class="loginCont">
            <div class="loginForm">
            <div class="info">{{error}}</div>
            <div class="inputbox">
                <label for="userCode">用户名：</label>
                <input type="text" class="input-text" id="userCode" v-model="userCode" placeholder="请输入用户名"
                       required/>
            </div>
            <div class="inputbox">
                <label for="userPassword">密码：</label>
                <input type="password" id="userPassword" v-model="userPassword" placeholder="请输入密码" required/>
            </div>
            <div class="subBtn">
                <div style="margin: auto;text-align: center">
                <input type="submit" value="登录"  @click="login"/>
<!--                <input type="reset" value="重置"/>-->
                </div>
            </div>
            </div>
        </section>
    </section>
</div>
</body>
</div>
</html>

<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
    new Vue({
        el:'#app',
        data(){
            return{
                userCode:'',
                userPassword:'',
                error:''
            }
        },
        methods:{
            login(){
                axios({
                    methods: 'get',
                    url:'user/login',
                    params:{
                        userCode:this.userCode,
                        userPassword:this.userPassword
                    }
                }).then(resp=>{
                    if (resp.data==='success'){
                        location.href='index.html'
                    }else{
                        this.error=resp.data
                    }
                })
            }
        }
    })
</script>
